<%@page import="com.sun.xml.internal.messaging.saaj.soap.impl.DetailImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page language="java" import="java.lang.*" %>
<%@ page import = "java.sql.SQLException" %>
<%@ page import = "com.seniorproject.aims.*" %>
<%@ page import = "com.seniorproject.aims.Status" %>

<%@ page import = "java.util.List" %>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Date"%>
<%@ page import = "java.util.Properties" %>
<%@ page import = "javax.servlet.ServletContext" %>
<%@ page import = "java.io.File" %>
<%@ page import = "java.io.InputStream" %>
<%@ page import = "java.io.FileInputStream" %>
<%@ page import = "java.sql.PreparedStatement" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link rel="stylesheet" href="css/stylev2.css" />
<link rel="stylesheet" href="css/validation.css" />
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css"/>	
<link rel="stylesheet" href="css/redmond/jquery-ui.css" type="text/css"/>

<!--  <script type="text/javascript" src="js/livevalidation_standalone.js"></script>   --> 
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script src="js/jquery.ajaxfileupload.js"></script>
<!-- <script type="text/javascript" src="js/student_add2_validation.js"></script>   -->

	<style type="text/css">
		a {
	      text-decoration:none;
	   }
	</style>

<script>
$(document).ready(function() {
	
	var patt = new RegExp("[#$%^*?!~`<>]");

	$('input[type="file"]').ajaxfileupload({
		'action' : 'UploadServletStudentAddNormal',
		'onComplete' : function(response) {
			$('#upload').hide();
			$('#message').show();
			
			var statusVal = JSON.stringify(response.status);

			if(statusVal == "false")
			{
				$("#message").html("<font color='red'>"+ JSON.stringify(response.message) +" </font>");
				
			}	
			if(statusVal == "true")
			{
				$("#message").html("<font color='green'>"+ JSON.stringify(response.message) +" </font>");
			}			
		},
		'onStart' : function() {
			$('#upload').show();
			$('#message').hide();
		}
	});
	
	$('#save').click(function(){
		
		 var check = "";
		 var error = "กรุณากรอก";
		//////////////////////////////////////////////////////////////
		 var personal_id = document.getElementById('personalId');
	 	 personal_id_value = personal_id.value;
	 	
	   	 if(patt.test(personal_id_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
		 }
	 	
	 	
	 	
		 //////////////////////////////////////////////////////////////
	     var title = document.getElementsByName('title');
		 var title_value;
		 
		  if(patt.test(title_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
		 
		 for(var i = 0; i < title.length; i++){
		    if(title[i].checked){
		        title_value = title[i].value;
		    }
		 }
		    
			if(title_value==null)
			{
				error = error + " คำนำหน้า";
				check="X";
			
			}
			else if (title_value=="etc")
			{
				var title_etc_box = document.getElementsByName('title_etc');
				var title_etc_box_value = title_etc_box.value;
				
					if(title_etc_box.value==null){
						
							error = error + " คำนำหน้าแบบกำหนดเอง";
							check="X";
						
					} 
					
			}
			//////////////////////////////////////////////////////////////
			 
			var name_th = document.getElementById('name');
			var name_th_value = name_th.value;
			if(name_th_value=="")
			{
				error = error + " ชื่อภาษาไทย";	
				check="X";
			}
			if(patt.test(name_th_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			//////////////////////////////////////////////////////////////
			 
			var surname_th = document.getElementById('surname');
			var surname_th_value = surname_th.value;
			if(surname_th_value=="")
			{
				error = error + " นามสกุลภาษาไทย";	
				check="X";
			}
			if(patt.test(surname_th_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			
			 //////////////////////////////////////////////////////////////
			var gender = document.getElementsByName('gender');
			var gender_value;
			
			 for(var j = 0; j < gender.length; j++){
				    if(gender[j].checked){
				        gender_value = gender[j].value;
				    }
				 }
		
			 if(gender_value==null)
			 {
				 error = error + " เพศ";
				 check="X";
			 }
			
				//////////////////////////////////////////////////////////////
			 
				var student_id = document.getElementById('studentId');
				var student_id_value = student_id.value;
				if(student_id_value=="")
				{
					error = error + " รหัสนักศึกษา";	
					check="X";
				}
				if(patt.test(student_id_value)) { 
					
					check="X";
					error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
				}
				
			 //////////////////////////////////////////////////////////////

			 var date_of_birth = document.getElementById('date_of_birth');
			 var date_of_birth_value = date_of_birth.value; 
			 
			 if(date_of_birth_value=="")
			 {
				 error = error + " วันเกิด";
				 check="X";
			 }
			 //////////////////////////////////////////////////////////////
			 var select_entrance = document.getElementById('entrance');		
			 var entrance_value = select_entrance.options[select_entrance.selectedIndex].value;	 
		
			if(entrance_value=="select")
			{
				error = error + " รูปแบบการเข้าศึกษา";	
				check="X";
				
			}
			 //////////////////////////////////////////////////////////////
			 var select_degree = document.getElementById('degree');
			 
			 var degree_value = select_degree.options[select_degree.selectedIndex].value;	 
			
			 if(degree_value=="select")
			 {
				 error = error + " ระดับการศึกษา";
				 check="X";
			 }
			 //////////////////////////////////////////////////////////////
			 var select_degree = document.getElementById('degree');		
			 var degree_value = select_degree.options[select_degree.selectedIndex].value;	 
		
			if(degree_value=="select")
			{
				error = error + " สถานะ";	
				check="X";
				
			}
			/////////////////////////////////////////////////////////
			 var start_date = document.getElementById('start_date');
			 var start_date_value = start_date.value; 
			 
			 if(start_date_value=="")
			 {
				 error = error + " วันที่เริ่มเข้าศึกษา";
				 check="X";
			 }
			 //////////////////////////////////////////////////////////////
			 var select_status = document.getElementById('status');		
			 var status_value = select_status.options[select_status.selectedIndex].value;	 
		
			if(status_value=="select")
			{
				error = error + " สถานะนักศึกษา";	
				check="X";
				
			}
			
			if(!error == "กรุณากรอก"){
				alert(error);
			}
			
			////////////////////get data ///////////////////
			
			
			var name_en = document.getElementById('name_en');
			var name_en_value = name_en.value;
			if(patt.test(name_en_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
		
			
			var surname_en = document.getElementById('surname_en');
			var surname_en_value = surname_en.value;
			if(patt.test(surname_en_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			
			
			
		     var marital_status = document.getElementsByName('marital_status');
			 var marital_status_value;
			 
			if(patt.test(marital_status_value)) { 
					
					check="X";
					error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			 
			 
			 for(var i = 0; i < marital_status.length; i++){
			    if(marital_status[i].checked){
			        marital_status_value = marital_status[i].value;
			    }
			 }
			 
			 
			var address = document.getElementById('address');
			var address_value = address.value;
			
			if(patt.test(address_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
		
			
			var tel = document.getElementById('phonenumber');
			var tel_value = tel.value;
			
			if(patt.test(tel_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			var patt_email = new RegExp("[#$%^*?!~`<>]");
			var email = document.getElementById('email');
			var email_value = email.value;
			
			if(patt_email.test(email_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			
			var facebook = document.getElementById('facebook');
			var facebook_value = facebook.value;
		
			
			if(patt.test(facebook_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			
			
			var father_name = document.getElementById('fatherName');
			var father_name_value = father_name.value;
			
			if(patt.test(father_name_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
		
			
			var father_address = document.getElementById('fatherAddress');
			var father_address_value = father_address.value;
			
			if(patt.test(father_address_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
		
			
		
			
			var father_tel = document.getElementById('fatherPhone');
			var father_tel_value = father_tel.value;
			
			if(patt.test(father_tel_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
		
			var mother_name = document.getElementById('motherName');
			var mother_name_value = mother_name.value;
			
			if(patt.test(mother_name_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			
			var mother_address = document.getElementById('motherAddress');
			var mother_address_value = mother_address.value;
		
			if(patt.test(mother_address_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
		
			
			var mother_tel = document.getElementById('motherPhone');
			var mother_tel_value = mother_tel.value;
			if(patt.test(mother_tel_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			
			
			
			var parent_name_value;
			var parent_address_value;
			var parent_tel_value;
			
		    var parent_choose = document.getElementsByName('parent_name');
		    var parent_choose_value;
			 
			 for(var i = 0; i < parent_choose.length; i++){
			    if(parent_choose[i].checked){
			        parent_choose_value = parent_choose[i].value;
			    }
			 }
			 
			if(parent_choose_value=="sameFather")
			{
				parent_name_value = father_name_value;
				parent_address_value = parent_address_value;
				parent_tel_value = parent_tel_value;			
			
			}
			else if(parent_choose_value=="sameMother"){
				parent_name_value = mother_name_value;
				parent_address_value = mother_address_value;
				parent_tel_value = mother_tel_value;
			
			}
			else if(parent_choose_value=="etc")
			{
				var parent_name = document.getElementById('parentName');
				var parent_address =document.getElementById('parentAddress');
				var parent_tel = document.getElementById('parentPhone');
					parent_name_value = parent_name.value;
					parent_address_value  = parent_address.value;
					parent_tel_value = parent_tel.value;
					if(patt.test(parent_name_value)||patt.test(parent_address_value)||patt.test(parent_tel_value)) { 
						
						check="X";
						error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
					}
				
			}
						
	
			
			var school = document.getElementById('school');
			var school_value = school.value;
			
			if(patt.test(school_value)) { 
				
				check="X";
				error = error +"กรุณาหลีกเลี่ยงอักขะพิเศษ";
			}
			
			var gpa = document.getElementById('gpa');
			var gpa_value = gpa.value;
			
			
			
			var lecturer = document.getElementById("lecturer_name").value;			
			var lecturer_name_value =  lecturer.substr(0,lecturer.indexOf(' '));	
			var lecturer_surname_value = lecturer.substr(lecturer.indexOf(' ')+1).trim();		
			
			var curriculum_id = "<%=request.getParameter("curriculum")%>";
			var department_id = "<%=request.getParameter("department")%>";
			
			/*			
			//final Checking
			alert("personal_id:"+personal_id_value);
			alert("title:"+title_value);
			alert("name_th:"+name_th_value);
			alert("surname_th:"+surname_th_value);
			alert("name_en:"+name_en_value);
			alert("surname_en:"+surname_en_value);
			alert("gender:"+gender_value);
			alert("marital_status:"+marital_status_value);
			alert("date_of_birth:"+date_of_birth_value); // 
			alert("address:"+address_value);
			alert("tel:"+tel_value);
			alert("email:"+email_value);
			alert("facebook:"+facebook_value);
			alert("picture:"+picture_value);
			alert("father_name:"+father_name_value);
			alert("father_address:"+father_address_value)
			alert("father_tel:"+father_tel_value);
			alert("mother_name:"+mother_name_value);
			alert("mother_address:"+mother_address_value);
			alert("mother_tel:"+mother_tel_value);
			alert("parent_name:"+parent_name_value);
			alert("parent_address:"+parent_address_value);
			alert("parent_tel:"+parent_tel_value); 
			alert("student_id:"+student_id_value);
			alert("entrance_id:"+entrance_value);
			alert("school:"+school_value);
			alert("gpa:"+gpa_value);
			alert("start_date:"+start_date_value);
			alert("status:"+status_value)
			alert("lecturer_name:"+lecturer_name_value);
			alert("lecturer_surname:"+lecturer_surname_value);
			alert("curriculum_id:"+curriculum_id);
			
			*/
			
			if(check=="")
			{
				/* AJAX */
				var xmlhttp;
				
				if(window.XMLHttpRequest) {
					// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp = new XMLHttpRequest();
				}
				else {
					// code for IE6, IE5
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				xmlhttp.onreadystatechange = function() {
					if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {									
					
						//alert("I'm back");
						var result = xmlhttp.responseText;
						alert("result:"+result);
						if(result=="fail"){
							alert("บันทึกข้อมูลไม่สำเร็จกรุณาตรวจสอบข้อมูล");
							
						}
						else if(result=="success"){
							alert("บันทึกข้อมูลสำเร็จ");
							window.location="/AIMS_Project/student_add.jsp";
							// redirect
							
						}else{
							alert("บันทึกข้อมูลไม่สำเร็จ");
							
						}
						
						//document.location.href = "admin_account.jsp";
					}
				}
				
				
				var parameter = "personal_id="+personal_id_value+
							    "&title_th="+title_value+
							    "&name_th="+name_th_value+
							    "&surname_th="+surname_th_value+
							    "&name_en="+name_en_value+
								"&surname_en="+surname_en_value+
								"&gender="+gender_value+
								"&marital_status="+marital_status_value+
								"&date_of_birth="+date_of_birth_value+
								"&address="+address_value+
								"&tel="+tel_value+
								"&email="+email_value+
								"&facebook="+facebook_value+
								"&father_name="+father_name_value+
								"&father_address="+father_address_value+
								"&father_tel="+father_tel_value+
								"&mother_name="+mother_name_value+
								"&mother_address="+mother_address_value+
								"&mother_address="+mother_address_value+
								"&parent_name="+parent_name_value+
								"&parent_address="+parent_address_value+
								"&parent_tel="+parent_tel_value+
								"&student_id="+student_id_value+
								"&entrance_id="+entrance_value+
								"&school="+school_value+
								"&gpa="+gpa_value+
								"&start_date="+start_date_value+
								"&status_id="+status_value+
								"&lecturer_name="+lecturer_name_value+
								"&lecturer_surname="+lecturer_surname_value+
								"&curriculum_id="+curriculum_id+
								"&department_id="+department_id;
									
				
				
				xmlhttp.open("POST", "student_add_normal_background.jsp?"+parameter, true);
				xmlhttp.send();
			}
			else{
					alert("กรุณาตรวจสอบความถูกต้องอีกครั้ง");
			}
				 
		
	});
	
});

$("#personalId").on('keydown', '#textbox', function(e) { 
	  var keyCode = e.keyCode || e.which; 

	  if (keyCode == 9) { 
			alert("Active");	    

	  } 
});

function parent_etc(){
	
	var parent_name_box = document.getElementById("parentName");
	var parent_address_box = document.getElementById("parentAddress");
	var parent_tel_box = document.getElementById("parentPhone");
	
	parent_name_box.readOnly = false;
	parent_address_box.readOnly = false;
	parent_tel_box.readOnly = false;

}
function parent_is_father(){
	
	var parent_name_box = document.getElementById("parentName");
	var parent_address_box = document.getElementById("parentAddress");
	var parent_tel_box = document.getElementById("parentPhone");
	
	parent_name_box.readOnly = true;
	parent_address_box.readOnly = true;
	parent_tel_box.readOnly = true;

}function parent_is_mother(){
	
	var parent_name_box = document.getElementById("parentName");
	var parent_address_box = document.getElementById("parentAddress");
	var parent_tel_box = document.getElementById("parentPhone");
	
	parent_name_box.readOnly = true;
	parent_address_box.readOnly = true;
	parent_tel_box.readOnly = true;

}

function search_name(name) {	
	if($('#namelist').find('option').length > 0) {
		
		$('#namelist').find('option').remove();
	}
	if(name != "") {
		/* AJAX */
		var xmlhttp;
		
		if(window.XMLHttpRequest) {
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp = new XMLHttpRequest();
		}
		else {
			// code for IE6, IE5
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				
				
				var jsonObj = JSON.parse(xmlhttp.responseText);
				
				if(jsonObj.length == 0) {
					// no data
				}
				else{
					for(i in jsonObj) {
						var text = jsonObj[i].nameTH+" "+jsonObj[i].surnameTH;
						var option = '<option value="'+text+'" >';
						
						$('#namelist').append(option);
					}
				}
			}
		}
		
		xmlhttp.open("POST", "search_name_lecturer.jsp?name="+name, true);
		xmlhttp.send();
	}			
}
</script>

<style type="text/css">
table {
    border-collapse: collapse:
    border-spacing: 0;
    border: 0px solid #bbb
    
    
}
table.center {

}
td,th {
    border: 2px solid #ddd;
    padding: 10px; 0px;
    text-align: left;
}						
tbody tr:nth-child(even)  td { background-color: #eee; }

</style>

</head>
<body>

<%

	
	String strUser = String.valueOf(session.getAttribute("sUser"));
	HttpSession htp_session = request.getSession();
			
	if (htp_session == null || htp_session.getAttribute("sUser") == null) {
	    // Forward the control to login.jsp if authentication fails or session expires
	    request.getRequestDispatcher("/login.jsp").forward(request,
	        response);
	}
	
	if("admin".equals(htp_session.getAttribute("sUser"))){%>
	<script>alert("This user dont have PERMISSION to access this zone.");</script>
	<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=admin_home.jsp"> 	
	<%}
		
	
	
	String department_id = request.getParameter("department");
	String curriculum_id = request.getParameter("curriculum");
	System.out.println("message_path:"+session.getAttribute("message_path"));
	
	System.out.println("Select Curriculum :"+curriculum_id);
	System.out.println("Select Depart:"+department_id);
	
	if(department_id==null||curriculum_id==null)
	{	
		System.out.println("Redirect");
		response.sendRedirect("student_add.jsp");	
	}
			
	
	//////////get permission ///////////
	
	String name = String.valueOf(session.getAttribute("name"));
	String surname = String.valueOf(session.getAttribute("surname"));
	String role_name = String.valueOf(session.getAttribute("student_role"));
	
	String department_id2 = String.valueOf(session.getAttribute("department_id"));

	
			
	System.out.println("name : " + name);///////////////////////////////
	System.out.println("department_id : " + department_id2);/////////////////////////
	
	
	Permission permission = new Permission(strUser,name);
	permission.setDepartmentId(department_id2);
	permission.setStudentCreate(Boolean.valueOf(String.valueOf(session.getAttribute("student_create"))));
	permission.setStudentDelete(Boolean.valueOf(String.valueOf(session.getAttribute("student_delete"))));
	permission.setStudentRead(Boolean.valueOf(String.valueOf(session.getAttribute("student_read"))));
	permission.setStudentUpdate(Boolean.valueOf(String.valueOf(session.getAttribute("student_update"))));
	
	String permiss = "";
	if(permission.getStudentCreate()) {
		permiss = permiss + "Add";
	}
	if(permission.getStudentUpdate()) {
		if("".equals(permiss)) {
			permiss = permiss + "Edit";
		} else {
			permiss = permiss + " Edit";
		}
	}
	if(permission.getStudentRead()) {
		if("".equals(permiss)) {
			permiss = permiss + "Read";
		} else {
			permiss = permiss + " Read";
		}
	}
	if(permission.getStudentDelete()) {
		if("".equals(permiss)) {
			permiss = permiss + "Delete";
		} else {
			permiss = permiss + " Delete";
		}
	}

	//check permission
	if(!permission.getStudentCreate()){%>
		<script>alert("This user dont have PERMISSION to access this zone.");</script>
		<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=student_home.jsp"> 	
	<%}

	//set Database Connection
	String hostProps = "";
	String usernameProps  = "";
	String passwordProps  = "";
	String databaseProps = "";
	
	try {
		//get current path
		ServletContext servletContext = request.getSession().getServletContext();
		
		InputStream input = servletContext.getResourceAsStream("/properties/connectDB.properties");
		Properties props = new Properties();
		
		props.load(input);

		hostProps  = props.getProperty("host");
		usernameProps  = props.getProperty("username");
		passwordProps  = props.getProperty("password");
		databaseProps = props.getProperty("database");
	} catch (Exception e) { 
		out.println(e);  
	}
	
	// connect database
	Connection connect = null;		
	try {
		Class.forName("com.mysql.jdbc.Driver");
	
		connect =  DriverManager.getConnection("jdbc:mysql://" + hostProps  + "/" + databaseProps +
				"?user=" + usernameProps  + "&password=" + passwordProps + "&characterEncoding=tis620" );
	
		if(connect != null){
			System.out.println("Database Connect Sucesses.");
		} else {
			System.out.println("Database Connect Failed.");	
		}

	} catch (Exception e) {
		out.println(e.getMessage());
		e.printStackTrace();
	}
	
	List<Status> status = new ArrayList<Status>();
	List<Entrance> entrance = new ArrayList<Entrance>();
	try{
		ResultSet rs_status = connect.createStatement().executeQuery("SELECT status_id, status_name " 
				+ " FROM status " + " ORDER BY status_id");
		
		while(rs_status.next()) {
			Status sta = new Status();
			
			
			sta.setStatusId(Integer.parseInt(rs_status.getString("status_id")));
			sta.setStatusName(rs_status.getString("status_name"));
			
			status.add(sta);
		}
		
		ResultSet rs_entrance = connect.createStatement().executeQuery("SELECT entrance_id, entrance_name " 
				+ " FROM entrance " + " ORDER BY entrance_id");
		
		while(rs_entrance.next()) {
			Entrance ent = new Entrance();
			
			
			ent.setEntranceId(Integer.parseInt(rs_entrance.getString("entrance_id")));
			ent.setEntranceName(rs_entrance.getString("entrance_name"));
			
			entrance.add(ent);
		}
		
	
		
	}catch(Exception a){
		out.println(a.getMessage());
		a.printStackTrace();
		
	};
	
	connect.close();

%>


<div id="page-wrap">
		<div id="inside">
			<table border="0">
				<tr style="font-size:24px">
					<td width="600" height="100" style= "background-color: #273b80;border: 0px ;padding: 0px; 0px;" >
						<div id="header_banner-2"></div>
					</td>
					
					<td width="680" height="100" style= "background-color: #273b80;border: 0px;padding: 0px; 0px;" >
						<p align="right"><label><font size="4" color="#ffffff">username : <%=strUser%>&nbsp;&nbsp;</font></label></p>
						<a href="logout.jsp"><p align="right"><label style="cursor: pointer;"><font size="3" color="#ffffff">log out &nbsp;</font></label></p></a>
					</td>
				</tr>
			</table>

				
				<div id="main-content-ac">
				
			<!-- 		<h2 style="padding-left: 2.5cm; color: #273b80;">เพิ่มข้อมูล2</h2>	 -->
			
				<br><br><br><br>

				<center>
					
					<input type="hidden" name="department" value="<%=department_id%>">
					<input type="hidden" name="curriculum" value="<%=curriculum_id%>">
					<table width="1000px" border="0">
						<form name="student_save_frm" method="post">
				        	<tr style="font-size:24px">
				        	
				                <td width="400" height="50">
				                	<font size="5"><strong>เลขประจำตัวประชาชน</strong></font>
				                </td>
				                <td width="600" height="50">
				                	<input type="text" id="personalId" name="personalId" style="font-size:18px" value="" required maxlength="13"/>
				                </td>
				                	      
				            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>คำนำหน้า</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	
		                      <label>
		                        <input type="radio" name="title" id="title" value="นาย" id="mr" />
		                        <font size="5">นาย</font>
		                      </label>
		                      &nbsp;&nbsp;&nbsp;&nbsp;
		                      <label>
		                        <input type="radio" name="title" id="title" value="นาง" id="mrs" />
		                        <font size="5">นาง</font>
		                      </label>
		                      &nbsp;&nbsp;&nbsp;&nbsp;
		                      <label>
		                        <input type="radio" name="title" id="title" value="นางสาว" id="miss" />
		                        <font size="5">นางสาว</font>
		                      </label>
		                      &nbsp;&nbsp;&nbsp;&nbsp;
		                      <label>
		                        <input type="radio" name="title" id="title" value="etc" id="etc" />
		                        <font size="5">อื่นๆ</font>
		                        &nbsp;&nbsp;
		                        <input type="text"  style="font-size:18px" size="10" id="title_etc" name="title_etc"/>
		                      </label>

		                </td>
		            </tr>
		                 
		            <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>ชื่อ</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<input name="name" id="name" type="text" style="font-size:18px" required/>
		                </td>
		            </tr>
		            
		            <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>นามสกุล</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<input name="surname" id="surname" type="text" style="font-size:18px" required/>
		                </td>
		                
		            </tr>
		              <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>ชื่อ(ภาษาอังกฤษ)</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<input name="name_en" id="name_en" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		              <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>นามสกุล(ภาษาอังกฤษ)</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<input name="surname_en" id="surname_en" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		            
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>เพศ</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		   
		                      <label>
		                        <input type="radio" name="gender" value="M" id="man" />
		                        <font size="5">ชาย</font></label>
		                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		                      <label>
		                        <input type="radio" name="gender" value="F" id="women" />
		                        <font size="5">หญิง</font></label>
		                </td>
		            </tr>
		             <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>สถานภาพ</strong></font>
		                </td>
		                <td height="50">
		   
		                      <label>
		                        <input type="radio" name="marital_status" id="marital_status" value="โสด" checked="checked" />
		                        <font size="5">โสด</font></label>
		                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		                      <label>
		                        <input type="radio" name="marital_status"id="marital_status" value="แต่งงาน" />
		                        <font size="5">แต่งงาน</font></label>
		                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		                      <label>
		                        <input type="radio" name="marital_status" id="marital_status" value="หย่าร้าง" />
		                        <font size="5">หย่าร้าง</font></label>
		                    
		                </td>
		            </tr>											
		            <tr style="font-size:24px">
		                <td height="50">
		
		                	<font size="5"><strong>วันเกิด (ว/ด/ป)</strong></font>
		                	<label><font size="5" color="#FF0000">*</font></label>
		                </td>

		                 <td height="50">
		                   <input type="date" id="date_of_birth" name="date_of_birth" required />

		                </td>
		            </tr>
		                
		            <tr style="font-size:24px">
		                <td height="50">
							<font size="5"><strong>ที่อยู่</strong></font>
		                </td>
		                <td height="50">
		                	<input name="address" id="address" type="text" style="font-size:18px" />
		                </td>
		           </tr>
		                
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>เบอร์โทรศัพท์</strong></font>
		                </td>
		                <td height="50">
		                	<input name="phonenumber" id="phonenumber" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
							<font size="5"><strong>E-mail</strong></font>
		                </td>
		                <td height="50">
		                	<input type="type" name="email" id="email" style="font-size:18px" />
		                </td>
		             </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
							<font size="5"><strong>Facebook</strong></font>
		                </td>
		                <td height="50">
		                	<input name="facebook" id="facebook" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		
				    
		            <tr style="font-size:24px">
		                <td height="50"><font size="5"><strong>ชื่อบิดา</strong></font>
		                </td>
		                <td height="50">
		                	<input name="fatherName" id ="fatherName" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>ที่อยู่บิดา</strong></font>
		                </td>
		                <td height="50">
		                	<textarea name="fatherAddress" id="fatherAddress" cols="50" rows="3"></textarea>
		              </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>เบอร์โทรศัพท์บิดา</strong></font>
		                </td>
		                <td height="50">
		                	<input name="fatherPhone" id="fatherPhone" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		            
		            <tr style="font-size:24px">
		                <td height="50"><font size="5"><strong>ชื่อมารดา</strong></font>
		                </td>
		                <td height="50">
		                	<input name="motherName" id="motherName" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>ที่อยู่มารดา</strong></font>
		                </td>
		                <td height="50">
		                	<textarea name="motherAddress" id="motherAddress" cols="50" rows="3"></textarea>
		                    
		              </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>เบอร์โทรศัพท์มารดา</strong></font>
		                </td>
		                <td height="50">
		                	<input name="motherPhone" id="motherPhone" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		              
		            <tr style="font-size:24px">
		                <td height="50"><font size="5"><strong>ชื่อผู้ปกครอง</strong></font>
		                </td>
		                <td height="50">	
		                    <input name="parent_name"id="parent_name" type="radio"  value="sameFather" onclick="parent_is_father()" />
		                    <font size="5">บิดา</font>
		                    &nbsp;&nbsp;&nbsp;
		                    <input name="parent_name" id="parent_name" type="radio" value="sameMother" onclick="parent_is_mother()"/>
		                    <font size="5">มารดา</font>
		                    &nbsp;&nbsp;&nbsp;
		                    <input name="parent_name" id="parent_name" type="radio"  checked="checked" value="etc" onclick="parent_etc()" />
		                    <font size="5">อื่นๆ</font>
		                    <input name="parentName" id="parentName" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>ที่อยู่ผู้ปกครอง</strong></font>
		                </td>
		                <td height="50">
		                	<textarea name="parentAddress" id="parentAddress" cols="50" rows="3"></textarea>
		              </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>เบอร์โทรศัพท์ผู้ปกครอง</strong></font>
		                </td>
		                <td height="50">
		                	<input name="parentPhone" id="parentPhone" type="text" style="font-size:18px" />
		                </td>
		            </tr>
		            
		            <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>รหัสนักศึกษา</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<input name="studentId" id="studentId" type="text" style="font-size:18px" required maxlength="7"/>
		                </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>Entrance</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<select name="entrance" id="entrance" style="font-size:18px">
		                        <option value="select">Select</option>
		                        
		                        
	                        	     <%
	                         		int num_ent = entrance.size();
	                       
	                         		for(int i =0;num_ent>0;num_ent--,i++)
	                         		{
	                         			
	                         			%>
	                         			 <option value="<%= entrance.get(i).getEntranceId()%>"><%= entrance.get(i).getEntranceName() %></option>
	                         			 
	                         			<% 
	                         			
	                         		}
	                         	%>
		                   
		                   
		                   
		                   
		                   
		                    </select>
		                </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>ระดับการศึกษา</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<select name="degree" id="degree" style="font-size:18px">
		                        <option value="select">Select</option>
		                        <option value="bachelor">ปริญญาตรี</option>
		                        <option value="master">ปริญญาโท</option>
		        			</select>
		                </td>
		            </tr>
		              
		            <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>โรงเรียนเดิม</strong></font>
		                </td>
		                <td height="50">
		                	<input name="school" id="school" type="text" style="font-size:18px" />
		        		
		                </td>
		            </tr>
		            
		            <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>GPA (ม.ปลาย)</strong></font>
		                </td>
		                <td height="50">
		                	<input name="gpa" id="gpa" type="text" style="font-size:18px" />
		        			
		                </td>
		            </tr>

					<tr style="font-size:24px">
		                <td height="50">

		                	<font size="5"><strong>วันที่เข้าศึกษา</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                   <input type="date" id="start_date" name="start_date"/>
		                
		                </td>
		            </tr>

		            
					<tr style="font-size:24px">
		                <td height="50">
							<font size="5"><strong>สถานะ</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<select name="status" id="status" style="font-size:18px">
		                        <option value="select">Select</option>
		      
		      					     <%
		                         		int num_sta = status.size();
		                       
		                         		for(int i =0;num_sta>0;num_sta--,i++)
		                         		{
		                         			
		                         			%>
		                         			 <option value="<%= status.get(i).getStatusId()%>"><%= status.get(i).getStatusName() %></option>
		                         			
		                         			<% 
		                         			
		                         		}
		                         	%>
		      
		      
		      
		                        
		        			</select>
		                </td>
		            </tr>
		            
		            <tr style="font-size:24px">
		                <td height="50">
		                	<font size="5"><strong>อาจารย์ที่ปรึกษา</strong></font>
				         			<label><font size="5" color="#FF0000">*</font></label>
		                </td>
		                <td height="50">
		                	<input name="lecturer_name" id="lecturer_name" type="text" style="font-size:18px" list="namelist" value="" onkeyup="search_name(this.value)" /> <!--  นามสุกล <input name="lecturer_surname" id="lecturer_surname" type="text" style="font-size:18px" />   -->
		                	<datalist id="namelist">
							</datalist>
		                </td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<font size="3" color="#FF0000">หมายเหตุ: * คือ ข้อมูลสำคัญ จำเป็นต้องกรอก</font>
		             	</td>
		             	<td></td>
		            </tr>
		
					<tr style="font-size:24px">
		                <td height="50">
		                	<center><input type="button" name="save" id="save"  value="save" class="buttonStyle"/></center>
		                </td>
		       </form>         
		                <td height="50">
		                	<center><a href="student_add.jsp"><button class="buttonStyle">cancel</button></a></center>
		                </td>
		            </tr>
				
			</table>
			
			</center>
			
							
					</br></br></br>
								

			<div style="clear: both;"></div>
				
			<div id="footer"></div>
			
		</div>		
			<div style="clear: both;"></div>		
   </div>

	
					
</body>
</html>